package com.ar4j.bench.test.ar4j;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;

import com.ar4j.bench.ar4j.domain.Category;
import com.ar4j.bench.ar4j.domain.Item;
import com.ar4j.bench.ar4j.domain.Product;
import com.ar4j.bench.ar4j.service.CategoryAr4jService;
import com.ar4j.bench.ar4j.service.ProductAr4jService;
import com.ar4j.bench.common.domain.ICategory;
import com.ar4j.bench.common.domain.IItem;
import com.ar4j.bench.common.domain.IProduct;
import com.ar4j.bench.common.service.ICategoryService;
import com.ar4j.bench.common.service.IProductService;
import com.ar4j.bench.test.synthetic.AbstractSyntheticBenchmarkTest;
import com.ar4j.spring.AutowiredAdapter;
import com.ar4j.spring.SpringActiveRecordAdapter;

/**
 * A JUnit test for running the full benchmark suite for the Ar4J libary.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/applicationContext-junit.xml" })
@TransactionConfiguration(transactionManager = "txManager", defaultRollback = false)
public class Ar4jSyntheticBenchmark extends AbstractSyntheticBenchmarkTest {

  @Autowired
  private CategoryAr4jService categoryService;
  
  @Autowired
  private ProductAr4jService productService;
  
  @AutowiredAdapter
  private SpringActiveRecordAdapter<Category> categoryAdapter;
  
  @AutowiredAdapter
  private SpringActiveRecordAdapter<Product> productAdapter;
  
  @AutowiredAdapter
  private SpringActiveRecordAdapter<Item> itemAdapter;
  
  
  @Override
  protected Class<? extends ICategory> getCategoryBaseClass() {
    return null; // its abstract, can't return one
  }

  @Override
  protected Class<? extends IProduct> getProductBaseClass() {
    return null; // its abstract, can't return one
  }
  
  @Override
  protected Class<? extends IItem> getItemBaseClass() {
    return null; // its abstract, can't return one
  }
  
  @Override
  protected ICategoryService getCategoryService() {
    return categoryService;
  }

  @Override
  protected IProductService getProductService() {
    return productService;
  }
  
  @Override
  protected String getName() {
    return "Ar4J";
  }

  @Override
  protected ICategory instantiateCategory() {
    return categoryAdapter.blank();
  }

  @Override
  protected IItem instantiateItem() {
    return itemAdapter.blank();
  }

  @Override
  protected IProduct instantiateProduct() {
    return productAdapter.blank();
  }

}
